package com.epmis.epmis.Service.impl;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.PutObjectRequest;
import com.epmis.epmis.Mapper.ConsoleUserMapper;
import com.epmis.epmis.Mapper.LoginMapper;
import com.epmis.epmis.Service.ConsoleUserService;
import com.epmis.epmis.pojo.*;
import com.epmis.epmis.utils.ExcelUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Service
public class ConsoleUserServiceImpl implements ConsoleUserService {
    @Resource
    ConsoleUserMapper consoleUserMapper;
    @Resource
    LoginMapper loginMapper;

    @Override
    public List<User> getAllUser(int id) {
        return consoleUserMapper.getAllUser(id);
    }

    @Override
    public List<User> getNoDepartmentUser(int id) {
        return consoleUserMapper.getNoDepartmentUser(id);
    }

    @Override
    public List<User> getDepartmentUser(int enterpriseId,int id) {
        return consoleUserMapper.getDepartmentUser(enterpriseId,id);
    }

    @Override
    public int createMember(HashMap<String, Object> map) {
        User user = new User();
        user.setPassword((String)map.get("password"));
        if(consoleUserMapper.findSameUsername((String)map.get("username")) != null){
            return 0;
        }
        user.setUsername((String)map.get("username"));
        user.setDepartment_id((int)map.get("department"));
        user.setPhoto("cat.jpg");
        if(loginMapper.findPhone((String)map.get("phone")) != null){
            return 1;
        }
        user.setPhone((String)map.get("phone"));
        user.setName((String)map.get("name"));
        if(loginMapper.findEmail((String)map.get("email")) != null){
            return 2;
        }
        user.setEmail((String)map.get("email"));
        user.setEnterprise_id((int)map.get("enterpriseId"));
        user.setPost_id((int)map.get("post"));
        HashMap<String,Object> newMap = new HashMap<>();
        newMap.put("number",map.get("number"));
        newMap.put("id",map.get("enterpriseId"));
        if(consoleUserMapper.findSameNumber(newMap) !=null){
            if(loginMapper.findEmail((String)map.get("email")) != null){
                return 3;
            }
        }
        user.setEmployee_id((String)map.get("number"));
        consoleUserMapper.createMember(user);
        return 4;
    }

    @Override
    public List<EnterpriseUser> getEnterpriseUser(int id) {
        return consoleUserMapper.getEnterpriseUser(id);
    }

    @Override
    public boolean addUser(User user) {
        int num = consoleUserMapper.addUser(user);
        if (num > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean updateUser(User user) {
        int num = consoleUserMapper.addupdateUserUser(user);
        if (num > 0){
            return true;
        }
        return false;
    }

    @Override
    public User getUpdateUser(int id) {
        return consoleUserMapper.getUpdateUser(id);
    }

    @Override
    public boolean addSonDepartment(Department department) {
        return consoleUserMapper.addSonDepartment(department);
    }

    @Override
    public List<EnterpriseUser> searchEnterpriseUser(String keyword, int id) {
        return consoleUserMapper.searchEnterpriseUser(keyword,id);
    }

    @Override
    public boolean addPost(Post post) {
        return consoleUserMapper.addPost(post);
    }

    @Override
    public boolean updatePost(Post post) {
        return consoleUserMapper.updatePost(post);
    }

    @Override
    public boolean deletePost(int id) {
        return consoleUserMapper.deletePost(id);
    }

    @Override
    public List<User> getDisableUsers(int id) {
        return consoleUserMapper.getDisableUsers(id);
    }

    @Override
    public boolean disableUser(String username) {
        int num = consoleUserMapper.disableUser(username);
        if (num > 0){
            return true;
        }
        return false;
    }

    @Override
    public List<Project> getProjectMessage(int id) {
        return consoleUserMapper.getProjectMessage(id);
    }

    @Override
    public List<Mission> getMissionMessage(int id) {
        return consoleUserMapper.getMissionMessage(id);
    }

    @Override
    public List<MissionProject> getMissionProjectMessage(int id) {
        return consoleUserMapper.getMissionProjectMessage(id);
    }

    @Override
    public List<Target> getTargetMessage(int id) {
        return consoleUserMapper.getTargetMessage(id);
    }

    @Override
    public List<Hour> getHourMessage(int id) {
        return consoleUserMapper.getHourMessage(id);
    }

    @Override
    public List<Cost> getCostMessage(int id) {
        return consoleUserMapper.getCostMessage(id);
    }

    @Override
    public List<Examine> getExamineMessage(int id) {
        return consoleUserMapper.getExamineMessage(id);
    }

    @Override
    public List<ExamineProcess> getExaminProcessMessage(int id) {
        return consoleUserMapper.getExaminProcessMessage(id);
    }

    @Override
    public boolean deleteProjectById(int id) {
        return consoleUserMapper.deleteProjectById(id);
    }

    @Override
    public boolean deleteMissionById(int id) {
        return consoleUserMapper.deleteMissionById(id);
    }

    @Override
    public boolean deleteMissionProjectById(int id) {
        return consoleUserMapper.deleteMissionProjectById(id);
    }

    @Override
    public boolean deleteTargetById(int id) {
        return consoleUserMapper.deleteTargetById(id);
    }

    @Override
    public boolean deleteCostById(int id) {
        return consoleUserMapper.deleteCostById(id);
    }

    @Override
    public boolean deleteExamineById(int id) {
        return consoleUserMapper.deleteExamineById(id);
    }

    @Override
    public boolean deleteHourById(int id) {
        return consoleUserMapper.deleteHourById(id);
    }

    @Override
    public boolean deleteExamineProcessById(int id) {
        return consoleUserMapper.deleteExamineProcessById(id);
    }

    @Override
    public List<ExamineProcess> uploadConsoleExcel(File file) {
        Workbook wb = null;
        List<ExamineProcess> list = new ArrayList();
        try {
            System.out.println(file.getPath());
            if (ExcelUtil.isExcel2007(file.getName())) {
                wb = new XSSFWorkbook(new FileInputStream(file));
            } else {
                wb = new HSSFWorkbook(new FileInputStream(file));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Sheet sheet = wb.getSheetAt(0);//获取第一张表
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {

            try {
                Row row = sheet.getRow(i);//获取索引为i的行，以0开始
                int examine_id = (int) row.getCell(0).getNumericCellValue();
                int examine_p_id = (int) row.getCell(1).getNumericCellValue();
                int next_p_id = (int) row.getCell(2).getNumericCellValue();

                String state = row.getCell(3).getStringCellValue() + "";
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//注意月份是MM
                row.getCell(4).setCellType(CellType.STRING);
                Date date = simpleDateFormat.parse(String.valueOf(row.getCell(4).getStringCellValue()));
                int enterprise_id = (int) row.getCell(5).getNumericCellValue();
                ExamineProcess examineProcess = new ExamineProcess();
                examineProcess.setExamine_id(examine_id);
                examineProcess.setExamine_p_id(examine_p_id);
                examineProcess.setNext_p_id(next_p_id);
                examineProcess.setEnterprise_id(enterprise_id);
                examineProcess.setState(state);
                examineProcess.setDate(date);
                list.add(examineProcess);
                consoleUserMapper.updateExamineProcess(examineProcess);
                wb.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return list;
    }

    @Override
    public int enableMember(int id) {
        return consoleUserMapper.enableMember(id);
    }

    @Override
    public String getConsoleExcel(int id) {
        List<ExamineProcess> list = consoleUserMapper.getExaminProcessMessage(id);
        String url = "";
        try {
            ClassPathResource classPathResource = new ClassPathResource("/files/temp2.xlsx");
            File exportFile = new File("temp1.xlsx");
            File templetFile = classPathResource.getFile();
            Workbook workBook;

            if (!exportFile.exists()) {
                exportFile.createNewFile();
            }
            FileOutputStream out = new FileOutputStream(exportFile);
            FileInputStream fis = new FileInputStream(templetFile);
            if (ExcelUtil.isExcel2007(templetFile.getPath())) {
                workBook = new XSSFWorkbook(fis);
            } else {
                workBook = new HSSFWorkbook(fis);
            }

            Sheet sheet = workBook.getSheetAt(0);

            int rowIndex = 1;
            for (ExamineProcess item : list) {
                Row row = sheet.createRow(rowIndex);
                row.createCell(0).setCellValue(item.getId());
                row.createCell(1).setCellValue(item.getExamine_id());
                row.createCell(2).setCellValue(item.getExamine_p_id());
                row.createCell(3).setCellValue(item.getState());
                row.createCell(4).setCellValue(item.getNext_p_id());
                row.createCell(5).setCellValue(item.getDate());
                row.createCell(6).setCellValue(item.getEnterprise_id());
                rowIndex++;
            }

            String endpoint = "oss-cn-shenzhen.aliyuncs.com";
// 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
            String accessKeyId = "LTAI5t5woVtxVbK6JdBWTdfD";
            String accessKeySecret = "T7QNkN3sSLU8YyTFq5JVfdcN7eYlpo";
// 填写Bucket名称。
            String bucketName = "zgtest123";

// 创建OSSClient实例。
            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

            workBook.write(out);
            out.flush();
            out.close();

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date date = new Date();
            String time = sdf.format(date);
            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, time + "-审批流程数据表", exportFile);
            ossClient.putObject(putObjectRequest);
            Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000 * 24);
            url = ossClient.generatePresignedUrl(bucketName, time + "-审批流程数据表", expiration).toString();
            System.out.println(url);
            ossClient.shutdown();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return url;
    }

    @Override
    public List<Hour> uploadConsoleTimeExcel(File file) {
        Workbook wb = null;
        List<Hour> list = new ArrayList();
        try {
            System.out.println(file.getPath());
            if (ExcelUtil.isExcel2007(file.getName())) {
                wb = new XSSFWorkbook(new FileInputStream(file));
            } else {
                wb = new HSSFWorkbook(new FileInputStream(file));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Sheet sheet = wb.getSheetAt(0);//获取第一张表
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {

            try {
                Row row = sheet.getRow(i);//获取索引为i的行，以0开始
//                int id = (int) row.getCell(1).getNumericCellValue();
                row.getCell(0).setCellType(CellType.NUMERIC);
                int registrant_id = (int) row.getCell(0).getNumericCellValue();

                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//注意月份是MM
                row.getCell(1).setCellType(CellType.STRING);
                Date work_date = simpleDateFormat.parse(String.valueOf(row.getCell(1).getStringCellValue()));

                row.getCell(2).setCellType(CellType.NUMERIC);
                double hours = row.getCell(2).getNumericCellValue();

                row.getCell(3).setCellType(CellType.STRING);
                String work_type = row.getCell(3).getStringCellValue() + "";

                row.getCell(4).setCellType(CellType.STRING);
                String description = row.getCell(4).getStringCellValue() + "";

                row.getCell(5).setCellType(CellType.NUMERIC);
                int enterprise_id = (int) row.getCell(5).getNumericCellValue();

                row.getCell(6).setCellType(CellType.NUMERIC);
                int mission_id = (int) row.getCell(6).getNumericCellValue();

                Hour hour = new Hour();
                hour.setRegistrant_id(registrant_id);
                hour.setWork_date(work_date);
                hour.setHour(hours);
                hour.setWork_type(work_type);
                hour.setDescription(description);
                hour.setEnterprise_id(enterprise_id);
                hour.setMission_id(mission_id);

                list.add(hour);
                consoleUserMapper.uploadConsoleTimeExcel(hour);
                wb.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return list;
    }

    @Override
    public String getConsoleTimeExcel(int id) {
        List<Hour> list = consoleUserMapper.getHourMessage(id);
        String url = "";
        try {
            ClassPathResource classPathResource = new ClassPathResource("/file/TimeExcel.xlsx");
            File exportFile = new File("temp1.xlsx");
            File templetFile = classPathResource.getFile();
            Workbook workBook;

            if (!exportFile.exists()) {
                exportFile.createNewFile();
            }
            FileOutputStream out = new FileOutputStream(exportFile);
            FileInputStream fis = new FileInputStream(templetFile);
            if (ExcelUtil.isExcel2007(templetFile.getPath())) {
                workBook = new XSSFWorkbook(fis);
            } else {
                workBook = new HSSFWorkbook(fis);
            }

            Sheet sheet = workBook.getSheetAt(0);

            int rowIndex = 1;
            for (Hour item : list) {
                Row row = sheet.createRow(rowIndex);
                row.createCell(0).setCellValue(item.getId());
                row.createCell(1).setCellValue(item.getRegistrant_id());
                row.createCell(2).setCellType(CellType.STRING);
                System.out.println(item.getWork_date());
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                row.getCell(2).setCellValue(sdf.format(item.getWork_date()));
                row.createCell(3).setCellValue(item.getHour());
                row.createCell(4).setCellValue(item.getWork_type());
                row.createCell(5).setCellValue(item.getDescription());
                row.createCell(6).setCellValue(item.getEnterprise_id());
                row.createCell(7).setCellValue(item.getMission_id());
                rowIndex++;
            }

            String endpoint = "oss-cn-shenzhen.aliyuncs.com";
// 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
            String accessKeyId = "LTAI5t5woVtxVbK6JdBWTdfD";
            String accessKeySecret = "T7QNkN3sSLU8YyTFq5JVfdcN7eYlpo";
// 填写Bucket名称。
            String bucketName = "zgtest123";

// 创建OSSClient实例。
            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

            workBook.write(out);
            out.flush();
            out.close();

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date date = new Date();
            String time = sdf.format(date);
            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, time + "-工时数据表", exportFile);
            ossClient.putObject(putObjectRequest);
            Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000 * 24);
            url = ossClient.generatePresignedUrl(bucketName, time + "-工时数据表", expiration).toString();
            System.out.println(url);
            ossClient.shutdown();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return url;
    }

    @Override
    public List<Examine> uploadConsoleExamineExcel(File file) {
        Workbook wb = null;
        List<Examine> list = new ArrayList();
        try {
            System.out.println(file.getPath());
            if (ExcelUtil.isExcel2007(file.getName())) {
                wb = new XSSFWorkbook(new FileInputStream(file));
            } else {
                wb = new HSSFWorkbook(new FileInputStream(file));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Sheet sheet = wb.getSheetAt(0);//获取第一张表
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {

            try {
                Row row = sheet.getRow(i);//获取索引为i的行，以0开始
//                int id = (int) row.getCell(1).getNumericCellValue();
                row.getCell(0).setCellType(CellType.STRING);
                String state = row.getCell(0).getStringCellValue();

                row.getCell(1).setCellType(CellType.STRING);
                String number = row.getCell(1).getStringCellValue();

                row.getCell(2).setCellType(CellType.STRING);
                String content = row.getCell(2).getStringCellValue();

                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//注意月份是MM
                row.getCell(3).setCellType(CellType.STRING);
                Date date = simpleDateFormat.parse(String.valueOf(row.getCell(3).getStringCellValue()));

                row.getCell(4).setCellType(CellType.STRING);
                String detail = row.getCell(4).getStringCellValue();

                row.getCell(5).setCellType(CellType.NUMERIC);
                int applicant_id = (int) row.getCell(5).getNumericCellValue();

                row.getCell(6).setCellType(CellType.STRING);
                String accessory_id = row.getCell(6).getStringCellValue();

                row.getCell(7).setCellType(CellType.NUMERIC);
                int type = (int) row.getCell(7).getNumericCellValue();

                row.getCell(8).setCellType(CellType.NUMERIC);
                int enterprise_id = (int) row.getCell(8).getNumericCellValue();

                Examine examine = new Examine();
                examine.setState(state);
                examine.setNumber(number);
                examine.setContent(content);
                examine.setDate(date);
                examine.setDetail(detail);
                examine.setApplicant_id(applicant_id);
                examine.setAccessory_id(accessory_id);
                examine.setType(type);
                examine.setEnterprise_id(enterprise_id);

                list.add(examine);
                consoleUserMapper.uploadConsoleExamineExcel(examine);
                wb.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return list;
    }

    @Override
    public String getConsoleExamineExcel(int id) {
        List<Examine> list = consoleUserMapper.getExamineMessage(id);
        String url = "";
        try {
            ClassPathResource classPathResource = new ClassPathResource("/file/ExamineExcel.xlsx");
            File exportFile = new File("temp1.xlsx");
            File templetFile = classPathResource.getFile();
            Workbook workBook;

            if (!exportFile.exists()) {
                exportFile.createNewFile();
            }
            FileOutputStream out = new FileOutputStream(exportFile);
            FileInputStream fis = new FileInputStream(templetFile);
            if (ExcelUtil.isExcel2007(templetFile.getPath())) {
                workBook = new XSSFWorkbook(fis);
            } else {
                workBook = new HSSFWorkbook(fis);
            }

            Sheet sheet = workBook.getSheetAt(0);

            int rowIndex = 1;
            for (Examine item : list) {
                Row row = sheet.createRow(rowIndex);
                row.createCell(0).setCellValue(item.getId());
                row.createCell(1).setCellValue(item.getState());
                row.createCell(2).setCellValue(item.getNumber());
                row.createCell(3).setCellValue(item.getContent());
                row.createCell(4).setCellType(CellType.STRING);
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                row.getCell(4).setCellValue(sdf.format(item.getDate()));
                row.createCell(5).setCellValue(item.getDetail());
                row.createCell(6).setCellValue(item.getApplicant_id());
                row.createCell(7).setCellValue(item.getAccessory_id());
                row.createCell(8).setCellValue(item.getType());
                row.createCell(9).setCellValue(item.getEnterprise_id());
                rowIndex++;
            }

            String endpoint = "oss-cn-shenzhen.aliyuncs.com";
// 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
            String accessKeyId = "LTAI5t5woVtxVbK6JdBWTdfD";
            String accessKeySecret = "T7QNkN3sSLU8YyTFq5JVfdcN7eYlpo";
// 填写Bucket名称。
            String bucketName = "zgtest123";

// 创建OSSClient实例。
            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

            workBook.write(out);
            out.flush();
            out.close();

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date date = new Date();
            String time = sdf.format(date);
            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, time + "-审核数据表", exportFile);
            ossClient.putObject(putObjectRequest);
            Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000);
            url = ossClient.generatePresignedUrl(bucketName, time + "-审核数据表", expiration).toString();
            System.out.println(url);
            ossClient.shutdown();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return url;
    }

    @Override
    public List<Cost> uploadConsoleCostExcel(File file) {
        Workbook wb = null;
        List<Cost> list = new ArrayList();
        try {
            System.out.println(file.getPath());
            if (ExcelUtil.isExcel2007(file.getName())) {
                wb = new XSSFWorkbook(new FileInputStream(file));
            } else {
                wb = new HSSFWorkbook(new FileInputStream(file));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Sheet sheet = wb.getSheetAt(0);//获取第一张表
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {

            try {
                Row row = sheet.getRow(i);//获取索引为i的行，以0开始

                row.getCell(0).setCellType(CellType.NUMERIC);
                int mission_id = (int) row.getCell(0).getNumericCellValue();

                row.getCell(1).setCellType(CellType.STRING);
                String information = row.getCell(1).getStringCellValue();

                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//注意月份是MM
                row.getCell(2).setCellType(CellType.STRING);
                Date date = simpleDateFormat.parse(String.valueOf(row.getCell(2).getStringCellValue()));

                row.getCell(3).setCellType(CellType.STRING);
                String finance = row.getCell(3).getStringCellValue();

                row.getCell(4).setCellType(CellType.NUMERIC);
                double budget = row.getCell(4).getNumericCellValue();

                row.getCell(5).setCellType(CellType.NUMERIC);
                double execute = row.getCell(5).getNumericCellValue();

                row.getCell(6).setCellType(CellType.STRING);
                String cost_state = row.getCell(6).getStringCellValue();

                row.getCell(7).setCellType(CellType.STRING);
                Date happen_date = simpleDateFormat.parse(String.valueOf(row.getCell(7).getStringCellValue()));

                row.getCell(8).setCellType(CellType.NUMERIC);
                int enterprise_id = (int) row.getCell(8).getNumericCellValue();

                Cost cost = new Cost();
                cost.setMission_id(mission_id);
                cost.setInformation(information);
                cost.setPayment_date(date);
                cost.setFinance(finance);
                cost.setBudget(budget);
                cost.setExecute(execute);
                cost.setCost_state(cost_state);
                cost.setHappen_date(happen_date);
                cost.setEnterprise_id(enterprise_id);
                list.add(cost);
                consoleUserMapper.uploadConsoleCostExcel(cost);
                wb.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return list;
    }

    @Override
    public String getConsoleCostExcel(int id) {
        List<Cost> list = consoleUserMapper.getCostMessage(id);
        String url = "";
        try {
            ClassPathResource classPathResource = new ClassPathResource("/file/CostExcel.xlsx");
            File exportFile = new File("temp1.xlsx");
            File templetFile = classPathResource.getFile();
            Workbook workBook;

            if (!exportFile.exists()) {
                exportFile.createNewFile();
            }
            FileOutputStream out = new FileOutputStream(exportFile);
            FileInputStream fis = new FileInputStream(templetFile);
            if (ExcelUtil.isExcel2007(templetFile.getPath())) {
                workBook = new XSSFWorkbook(fis);
            } else {
                workBook = new HSSFWorkbook(fis);
            }

            Sheet sheet = workBook.getSheetAt(0);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            int rowIndex = 1;
            for (Cost item : list) {

                Row row = sheet.createRow(rowIndex);
                row.createCell(0).setCellValue(item.getId());
                row.createCell(1).setCellValue(item.getMission_id());
                row.createCell(2).setCellValue(item.getInformation());
                row.createCell(3).setCellType(CellType.STRING);
                if (item.getPayment_date() != null) {
                    row.getCell(3).setCellValue(sdf.format(item.getPayment_date()));
                }
                row.createCell(4).setCellValue(item.getFinance());
                row.createCell(5).setCellValue(item.getBudget());
                row.createCell(6).setCellValue(item.getExecute());
                row.createCell(7).setCellValue(item.getCost_state());
                if (item.getHappen_date() != null) {
                    row.createCell(8).setCellValue(sdf.format(item.getHappen_date()));
                }
                row.createCell(9).setCellValue(item.getEnterprise_id());
                rowIndex++;
            }

            String endpoint = "oss-cn-shenzhen.aliyuncs.com";
// 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
            String accessKeyId = "LTAI5t5woVtxVbK6JdBWTdfD";
            String accessKeySecret = "T7QNkN3sSLU8YyTFq5JVfdcN7eYlpo";
// 填写Bucket名称。
            String bucketName = "zgtest123";

// 创建OSSClient实例。
            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

            workBook.write(out);
            out.flush();
            out.close();

            Date date = new Date();
            String time = sdf.format(date);
            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, time + "-费用数据表", exportFile);
            ossClient.putObject(putObjectRequest);
            Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000);
            url = ossClient.generatePresignedUrl(bucketName, time + "-费用数据表", expiration).toString();
            System.out.println(url);
            ossClient.shutdown();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return url;
    }

    @Override
    public List<Target> uploadConsoleTargetExcel(File file) {
        Workbook wb = null;
        List<Target> list = new ArrayList();
        try {
            System.out.println(file.getPath());
            if (ExcelUtil.isExcel2007(file.getName())) {
                wb = new XSSFWorkbook(new FileInputStream(file));
            } else {
                wb = new HSSFWorkbook(new FileInputStream(file));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Sheet sheet = wb.getSheetAt(0);//获取第一张表
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {

            try {
                Row row = sheet.getRow(i);//获取索引为i的行，以0开始

                row.getCell(0).setCellType(CellType.NUMERIC);
                int mission_id = (int) row.getCell(0).getNumericCellValue();

                row.getCell(1).setCellType(CellType.STRING);
                String unit = row.getCell(1).getStringCellValue();

                row.getCell(2).setCellType(CellType.STRING);
                String initial_value = row.getCell(2).getStringCellValue();

                row.getCell(3).setCellType(CellType.STRING);
                String target_value = row.getCell(3).getStringCellValue();

                row.getCell(4).setCellType(CellType.STRING);
                String current_value = row.getCell(4).getStringCellValue();

                row.getCell(5).setCellType(CellType.STRING);
                String standard = row.getCell(5).getStringCellValue();

                row.getCell(6).setCellType(CellType.STRING);
                String Texplain = row.getCell(6).getStringCellValue();

                row.getCell(7).setCellType(CellType.STRING);
                String feedback = row.getCell(7).getStringCellValue();

                row.getCell(8).setCellType(CellType.STRING);
                String target_status = row.getCell(8).getStringCellValue();

                row.getCell(9).setCellType(CellType.NUMERIC);
                int enterprise_id = (int) row.getCell(9).getNumericCellValue();

                Target target = new Target();
                target.setMission_id(mission_id);
                target.setUnit(unit);
                target.setInitial_value(initial_value);
                target.setTarget_status(target_value);
                target.setCurrent_value(current_value);
                target.setStandard(standard);
                target.setTarget_status(Texplain);
                target.setFeedback(feedback);
                target.setTarget_status(target_status);
                target.setEnterprise_id(enterprise_id);
                list.add(target);
                consoleUserMapper.uploadConsoleTargetExcel(target);
                wb.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return list;
    }

    @Override
    public String getConsoleTargetExcel(int id) {
        List<Target> list = consoleUserMapper.getTargetMessage(id);
        String url = "";
        try {
            ClassPathResource classPathResource = new ClassPathResource("/file/TargetExcel.xlsx");
            File exportFile = new File("temp1.xlsx");
            File templetFile = classPathResource.getFile();
            Workbook workBook;

            if (!exportFile.exists()) {
                exportFile.createNewFile();
            }
            FileOutputStream out = new FileOutputStream(exportFile);
            FileInputStream fis = new FileInputStream(templetFile);
            if (ExcelUtil.isExcel2007(templetFile.getPath())) {
                workBook = new XSSFWorkbook(fis);
            } else {
                workBook = new HSSFWorkbook(fis);
            }

            Sheet sheet = workBook.getSheetAt(0);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            int rowIndex = 1;
            for (Target item : list) {

                Row row = sheet.createRow(rowIndex);
                row.createCell(0).setCellValue(item.getId());
                row.createCell(1).setCellValue(item.getMission_id());
                row.createCell(2).setCellValue(item.getUnit());
                row.createCell(3).setCellValue(item.getInitial_value());
                row.createCell(4).setCellValue(item.getTarget_value());
                row.createCell(5).setCellValue(item.getCurrent_value());
                row.createCell(6).setCellValue(item.getStandard());
                row.createCell(7).setCellValue(item.getTexplain());
                row.createCell(8).setCellValue(item.getFeedback());
                row.createCell(9).setCellValue(item.getTarget_value());
                row.createCell(10).setCellValue(item.getEnterprise_id());
                rowIndex++;
            }

            String endpoint = "oss-cn-shenzhen.aliyuncs.com";
// 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
            String accessKeyId = "LTAI5t5woVtxVbK6JdBWTdfD";
            String accessKeySecret = "T7QNkN3sSLU8YyTFq5JVfdcN7eYlpo";
// 填写Bucket名称。
            String bucketName = "zgtest123";

// 创建OSSClient实例。
            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

            workBook.write(out);
            out.flush();
            out.close();

            Date date = new Date();
            String time = sdf.format(date);
            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, time + "-目标数据表", exportFile);
            ossClient.putObject(putObjectRequest);
            Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000);
            url = ossClient.generatePresignedUrl(bucketName, time + "-目标数据表", expiration).toString();
            System.out.println(url);
            ossClient.shutdown();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return url;
    }

    @Override
    public List<MissionProject> uploadConsoleMissionProjectExcel(File file) {
        Workbook wb = null;
        List<MissionProject> list = new ArrayList();
        try {
            System.out.println(file.getPath());
            if (ExcelUtil.isExcel2007(file.getName())) {
                wb = new XSSFWorkbook(new FileInputStream(file));
            } else {
                wb = new HSSFWorkbook(new FileInputStream(file));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Sheet sheet = wb.getSheetAt(0);//获取第一张表
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {

            try {
                Row row = sheet.getRow(i);//获取索引为i的行，以0开始

                row.getCell(0).setCellType(CellType.NUMERIC);
                int mission_id = (int) row.getCell(0).getNumericCellValue();

                row.getCell(1).setCellType(CellType.STRING);
                String phase = row.getCell(1).getStringCellValue();

                row.getCell(2).setCellType(CellType.STRING);
                String PM_state = row.getCell(2).getStringCellValue();

                row.getCell(3).setCellType(CellType.NUMERIC);
                int father_id = (int) row.getCell(3).getNumericCellValue();

                row.getCell(4).setCellType(CellType.NUMERIC);
                double prospect_hour = row.getCell(4).getNumericCellValue();

                row.getCell(5).setCellType(CellType.NUMERIC);
                double hour = row.getCell(5).getNumericCellValue();

                row.getCell(6).setCellType(CellType.NUMERIC);
                int enterprise_id = (int) row.getCell(6).getNumericCellValue();

                row.getCell(7).setCellType(CellType.STRING);
                String rel_mission_id = row.getCell(7).getStringCellValue();


                MissionProject missionProject = new MissionProject();
                missionProject.setMission_id(mission_id);
                missionProject.setPhase(phase);
                missionProject.setPM_state(PM_state);
                missionProject.setFather_id(father_id);
                missionProject.setProspect_hour(prospect_hour);
                missionProject.setHour(hour);
                missionProject.setEnterprise_id(enterprise_id);
                missionProject.setRel_mission_id(rel_mission_id);
                list.add(missionProject);
                consoleUserMapper.uploadConsoleMissionProjectExcel(missionProject);
                wb.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return list;
    }

    @Override
    public String getConsoleMissionProjectExcel(int id) {
        List<MissionProject> list = consoleUserMapper.getMissionProjectMessage(id);
        String url = "";
        try {
            ClassPathResource classPathResource = new ClassPathResource("/file/TargetExcel.xlsx");
            File exportFile = new File("temp1.xlsx");
            File templetFile = classPathResource.getFile();
            Workbook workBook;

            if (!exportFile.exists()) {
                exportFile.createNewFile();
            }
            FileOutputStream out = new FileOutputStream(exportFile);
            FileInputStream fis = new FileInputStream(templetFile);
            if (ExcelUtil.isExcel2007(templetFile.getPath())) {
                workBook = new XSSFWorkbook(fis);
            } else {
                workBook = new HSSFWorkbook(fis);
            }

            Sheet sheet = workBook.getSheetAt(0);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            int rowIndex = 1;
            for (MissionProject item : list) {

                Row row = sheet.createRow(rowIndex);
                row.createCell(0).setCellValue(item.getId());
                row.createCell(1).setCellValue(item.getMission_id());
                row.createCell(2).setCellValue(item.getPhase());
                row.createCell(3).setCellValue(item.getPM_state());
                row.createCell(4).setCellValue(item.getFather_id());
                row.createCell(5).setCellValue(item.getProspect_hour());
                row.createCell(6).setCellValue(item.getHour());
                row.createCell(7).setCellValue(item.getEnterprise_id());
                row.createCell(8).setCellValue(item.getRel_mission_id());
                rowIndex++;
            }

            String endpoint = "oss-cn-shenzhen.aliyuncs.com";
// 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
            String accessKeyId = "LTAI5t5woVtxVbK6JdBWTdfD";
            String accessKeySecret = "T7QNkN3sSLU8YyTFq5JVfdcN7eYlpo";
// 填写Bucket名称。
            String bucketName = "zgtest123";

// 创建OSSClient实例。
            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

            workBook.write(out);
            out.flush();
            out.close();

            Date date = new Date();
            String time = sdf.format(date);
            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, time + "-项目任务数据表", exportFile);
            ossClient.putObject(putObjectRequest);
            Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000);
            url = ossClient.generatePresignedUrl(bucketName, time + "-项目任务数据表", expiration).toString();
            System.out.println(url);
            ossClient.shutdown();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return url;
    }

    @Override
    public List<Mission> uploadConsoleMissionExcel(File file) {
        Workbook wb = null;
        List<Mission> list = new ArrayList();
        try {
            System.out.println(file.getPath());
            if (ExcelUtil.isExcel2007(file.getName())) {
                wb = new XSSFWorkbook(new FileInputStream(file));
            } else {
                wb = new HSSFWorkbook(new FileInputStream(file));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Sheet sheet = wb.getSheetAt(0);//获取第一张表
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            try {
                Row row = sheet.getRow(i);//获取索引为i的行，以0开始

                row.getCell(0).setCellType(CellType.NUMERIC);
                int status = (int) row.getCell(0).getNumericCellValue();

                row.getCell(1).setCellType(CellType.STRING);
                String title = row.getCell(1).getStringCellValue();

                row.getCell(2).setCellType(CellType.NUMERIC);
                int project_id = (int) row.getCell(2).getNumericCellValue();

                row.getCell(3).setCellType(CellType.NUMERIC);
                int creator_id = (int) row.getCell(3).getNumericCellValue();

                row.getCell(4).setCellType(CellType.STRING);
                Date create_date = sdf.parse(String.valueOf(row.getCell(4).getStringCellValue()));

                row.getCell(5).setCellType(CellType.STRING);
                String type = row.getCell(5).getStringCellValue();

                row.getCell(6).setCellType(CellType.NUMERIC);
                int principal_id = (int) row.getCell(6).getNumericCellValue();

                row.getCell(7).setCellType(CellType.STRING);
                String participant_id = row.getCell(7).getStringCellValue();

                row.getCell(8).setCellType(CellType.STRING);
                String priority = row.getCell(8).getStringCellValue();

                row.getCell(9).setCellType(CellType.STRING);
                Date start_date = sdf.parse(String.valueOf(row.getCell(9).getStringCellValue()));

                row.getCell(10).setCellType(CellType.STRING);
                Date over_date = sdf.parse(String.valueOf(row.getCell(10).getStringCellValue()));

                row.getCell(11).setCellType(CellType.STRING);
                String description = row.getCell(11).getStringCellValue();

                row.getCell(12).setCellType(CellType.STRING);
                String before_id = row.getCell(12).getStringCellValue();

                row.getCell(13).setCellType(CellType.STRING);
                String after_id = row.getCell(13).getStringCellValue();

                row.getCell(14).setCellType(CellType.NUMERIC);
                int delete_state = (int) row.getCell(14).getNumericCellValue();

                row.getCell(15).setCellType(CellType.NUMERIC);
                int enterprise_id = (int) row.getCell(15).getNumericCellValue();

                Mission mission = new Mission();
                mission.setStatus(status);
                mission.setTitle(title);
                mission.setProject_id(project_id);
                mission.setCreator_id(creator_id);
                mission.setCreate_date(create_date);
                mission.setType(type);
                mission.setPrincipal_id(principal_id);
                mission.setParticipant_id(participant_id);
                mission.setPriority(priority);
                mission.setStart_date(start_date);
                mission.setOver_date(over_date);
                mission.setDescription(description);
                mission.setBefore_id(before_id);
                mission.setAfter_id(after_id);
                mission.setDelete_state(delete_state);
                mission.setEnterprise_id(enterprise_id);
                list.add(mission);
                consoleUserMapper.uploadConsoleMissionExcel(mission);
                wb.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return list;
    }

    @Override
    public String getConsoleMissionExcel(int id) {
        List<Mission> list = consoleUserMapper.getMissionMessage(id);
        String url = "";
        try {
            ClassPathResource classPathResource = new ClassPathResource("/file/MissionExcel.xlsx");
            File exportFile = new File("temp1.xlsx");
            File templetFile = classPathResource.getFile();
            Workbook workBook;

            if (!exportFile.exists()) {
                exportFile.createNewFile();
            }
            FileOutputStream out = new FileOutputStream(exportFile);
            FileInputStream fis = new FileInputStream(templetFile);
            if (ExcelUtil.isExcel2007(templetFile.getPath())) {
                workBook = new XSSFWorkbook(fis);
            } else {
                workBook = new HSSFWorkbook(fis);
            }

            Sheet sheet = workBook.getSheetAt(0);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            int rowIndex = 1;
            for (Mission item : list) {
                Row row = sheet.createRow(rowIndex);
                row.createCell(0).setCellValue(item.getId());
                row.createCell(1).setCellValue(item.getStatus());
                row.createCell(2).setCellValue(item.getTitle());
                row.createCell(3).setCellValue(item.getProject_id());
                row.createCell(4).setCellValue(item.getCreator_id());
                row.createCell(5).setCellValue(item.getCreate_date());
                row.createCell(6).setCellValue(item.getType());
                row.createCell(7).setCellValue(item.getPrincipal_id());
                row.createCell(8).setCellValue(item.getParticipant_id());
                row.createCell(9).setCellValue(item.getPriority());
                row.createCell(10).setCellValue(item.getStart_date());
                row.createCell(11).setCellValue(item.getOver_date());
                row.createCell(12).setCellValue(item.getDescription());
                row.createCell(13).setCellValue(item.getBefore_id());
                row.createCell(14).setCellValue(item.getAfter_id());
                row.createCell(15).setCellValue(item.getDelete_state());
                row.createCell(16).setCellValue(item.getEnterprise_id());
                rowIndex++;
            }

            String endpoint = "oss-cn-shenzhen.aliyuncs.com";
// 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
            String accessKeyId = "LTAI5t5woVtxVbK6JdBWTdfD";
            String accessKeySecret = "T7QNkN3sSLU8YyTFq5JVfdcN7eYlpo";
// 填写Bucket名称。
            String bucketName = "zgtest123";

// 创建OSSClient实例。
            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

            workBook.write(out);
            out.flush();
            out.close();

            Date date = new Date();
            String time = sdf.format(date);
            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, time + "-任务数据表", exportFile);
            ossClient.putObject(putObjectRequest);
            Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000);
            url = ossClient.generatePresignedUrl(bucketName, time + "-任务数据表", expiration).toString();
            System.out.println(url);
            ossClient.shutdown();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return url;
    }

    @Override
    public List<Project> uploadConsoleProjectExcel(File file) {
        Workbook wb = null;
        List<Project> list = new ArrayList();
        try {
            System.out.println(file.getPath());
            if (ExcelUtil.isExcel2007(file.getName())) {
                wb = new XSSFWorkbook(new FileInputStream(file));
            } else {
                wb = new HSSFWorkbook(new FileInputStream(file));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Sheet sheet = wb.getSheetAt(0);//获取第一张表
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            try {
                Row row = sheet.getRow(i);//获取索引为i的行，以0开始

                row.getCell(0).setCellType(CellType.STRING);
                String project_name = row.getCell(0).getStringCellValue();

                row.getCell(1).setCellType(CellType.STRING);
                String project_number = row.getCell(1).getStringCellValue();

                row.getCell(2).setCellType(CellType.NUMERIC);
                int rouge = (int) row.getCell(2).getNumericCellValue();

                row.getCell(3).setCellType(CellType.STRING);
                String description = row.getCell(3).getStringCellValue();

                row.getCell(4).setCellType(CellType.STRING);
                String member_id = row.getCell(4).getStringCellValue();

                row.getCell(5).setCellType(CellType.STRING);
                String state = row.getCell(5).getStringCellValue();

                row.getCell(6).setCellType(CellType.STRING);
                String state_description = row.getCell(6).getStringCellValue();

                row.getCell(7).setCellType(CellType.STRING);
                String customer_unit = row.getCell(7).getStringCellValue();

                row.getCell(8).setCellType(CellType.STRING);
                String customer_representative = row.getCell(8).getStringCellValue();

                row.getCell(9).setCellType(CellType.STRING);
                String project_type = row.getCell(9).getStringCellValue();

                row.getCell(10).setCellType(CellType.STRING);
                Date start_date = sdf.parse(String.valueOf(row.getCell(10).getStringCellValue()));

                row.getCell(11).setCellType(CellType.STRING);
                Date over_date = sdf.parse(String.valueOf(row.getCell(11).getStringCellValue()));

                row.getCell(12).setCellType(CellType.NUMERIC);
                Integer top_state = (int)row.getCell(12).getNumericCellValue();

                row.getCell(13).setCellType(CellType.NUMERIC);
                Integer delete_state = (int)row.getCell(13).getNumericCellValue();

                row.getCell(14).setCellType(CellType.NUMERIC);
                Integer principal_id = (int) row.getCell(14).getNumericCellValue();

                row.getCell(15).setCellType(CellType.NUMERIC);
                Integer creator_id = (int) row.getCell(15).getNumericCellValue();

                row.getCell(16).setCellType(CellType.STRING);
                Date create_date = sdf.parse(String.valueOf(row.getCell(16).getStringCellValue()));

                row.getCell(17).setCellType(CellType.NUMERIC);
                int enterprise_id = (int) row.getCell(17).getNumericCellValue();

                row.getCell(18).setCellType(CellType.NUMERIC);
                int deleter_id = (int) row.getCell(18).getNumericCellValue();

                row.getCell(19).setCellType(CellType.STRING);
                Date delete_date = sdf.parse(String.valueOf(row.getCell(19).getStringCellValue()));


                Project project = new Project();
                list.add(project);
                project.setProject_name(project_name);
                project.setProject_number(project_number);
                project.setRouge(rouge);
                project.setDescription(description);
                project.setMember_id(member_id);
                project.setState(state);
                project.setState_description(state_description);
                project.setCustomer_unit(customer_unit);
                project.setCustomer_representative(customer_representative);
                project.setProject_type(project_type);
                project.setStart_date(start_date);
                project.setOver_date(over_date);
                project.setTop_state(top_state);
                project.setDelete_state(delete_state);
                project.setPrincipal_id(principal_id);
                project.setCreator_id(creator_id);
                project.setCreate_date(create_date);
                project.setEnterprise_id(enterprise_id);
                project.setDeleter_id(deleter_id);
                project.setDelete_date(delete_date);

                consoleUserMapper.uploadConsoleProjectExcel(project);
                wb.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return list;
    }

    @Override
    public String getConsoleProjectExcel(int id) {
        List<Project> list = consoleUserMapper.getProjectMessage(id);
        String url = "";
        try {
            ClassPathResource classPathResource = new ClassPathResource("/file/ProjectExcel.xlsx");
            File exportFile = new File("temp1.xlsx");
            File templetFile = classPathResource.getFile();
            Workbook workBook;

            if (!exportFile.exists()) {
                exportFile.createNewFile();
            }
            FileOutputStream out = new FileOutputStream(exportFile);
            FileInputStream fis = new FileInputStream(templetFile);
            if (ExcelUtil.isExcel2007(templetFile.getPath())) {
                workBook = new XSSFWorkbook(fis);
            } else {
                workBook = new HSSFWorkbook(fis);
            }

            Sheet sheet = workBook.getSheetAt(0);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            int rowIndex = 1;
            for (Project item : list) {
                Row row = sheet.createRow(rowIndex);
                row.createCell(0).setCellValue(item.getId());
                row.createCell(1).setCellValue(item.getProject_name());
                row.createCell(2).setCellValue(item.getProject_number());
                row.createCell(3).setCellValue(item.getRouge());
                row.createCell(4).setCellValue(item.getDescription());
                row.createCell(4).setCellValue(item.getMember_id());
                row.createCell(5).setCellValue(item.getState());
                row.createCell(6).setCellValue(item.getState_description());
                row.createCell(7).setCellValue(item.getCustomer_unit());
                row.createCell(8).setCellValue(item.getCustomer_representative());
                row.createCell(9).setCellValue(item.getProject_type());
                row.createCell(10).setCellValue(item.getStart_date());
                row.createCell(11).setCellValue(item.getOver_date());
                row.createCell(12).setCellValue(item.getTop_state());
                row.createCell(13).setCellValue(item.getDelete_state());
                row.createCell(14).setCellValue(item.getDescription());
                row.createCell(15).setCellValue(item.getPrincipal_id());
                row.createCell(16).setCellValue(item.getCreator_id());
                row.createCell(17).setCellValue(item.getCreate_date());
                row.createCell(18).setCellValue(item.getEnterprise_id());
                row.createCell(19).setCellValue(item.getDeleter_id());
                row.createCell(20).setCellValue(item.getDelete_date());
                rowIndex++;
            }

            String endpoint = "oss-cn-shenzhen.aliyuncs.com";
// 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
            String accessKeyId = "LTAI5t5woVtxVbK6JdBWTdfD";
            String accessKeySecret = "T7QNkN3sSLU8YyTFq5JVfdcN7eYlpo";
// 填写Bucket名称。
            String bucketName = "zgtest123";

// 创建OSSClient实例。
            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

            workBook.write(out);
            out.flush();
            out.close();

            Date date = new Date();
            String time = sdf.format(date);
            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, time + "-项目数据表", exportFile);
            ossClient.putObject(putObjectRequest);
            Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000);
            url = ossClient.generatePresignedUrl(bucketName, time + "-项目数据表", expiration).toString();
            System.out.println(url);
            ossClient.shutdown();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return url;
    }

    @Override
    public boolean deleteByIdList(ArrayList<Integer> idlist, String tablename) {
        boolean result = false;
        switch (tablename) {
            case "project":
                for (Integer id : idlist) {
                    result = consoleUserMapper.deleteProjectById(id);
                }
                break;
            case "mission":
                for (Integer id : idlist) {
                    result = consoleUserMapper.deleteMissionById(id);
                }
                break;
            case "projectMission":
                for (Integer id : idlist) {
                    result = consoleUserMapper.deleteMissionProjectById(id);
                }
                break;
            case "target":
                for (Integer id : idlist) {
                    result = consoleUserMapper.deleteTargetById(id);
                }
                break;
            case "examine":
                for (Integer id : idlist) {
                    result = consoleUserMapper.deleteExamineById(id);
                }
                break;
            case "cost":
                for (Integer id : idlist) {
                    result = consoleUserMapper.deleteCostById(id);
                }
                break;
            case "time":
                for (Integer id : idlist) {
                    result = consoleUserMapper.deleteHourById(id);
                }
                break;
            case "examineProcess":
                for (Integer id : idlist) {
                    result = consoleUserMapper.deleteExamineProcessById(id);
                }
                break;
        }
        return result;
    }

    @Override
    public List<Post> getAllPost(int id) {
        return consoleUserMapper.getAllPost(id);
    }

    @Override
    public int updateMember(HashMap<String, Object> map) {
        User user = new User();
        user.setPassword((String)map.get("password"));
        user.setId((int)map.get("id"));
        if(consoleUserMapper.findSameUsername((String)map.get("username")) != null){
            return 0;
        }
        user.setUsername((String)map.get("username"));
        user.setDepartment_id((int)map.get("department"));
        if(loginMapper.findPhone((String)map.get("phone")) != null){
            return 1;
        }
        user.setPhone((String)map.get("phone"));
        user.setName((String)map.get("name"));
        if(loginMapper.findEmail((String)map.get("email")) != null){
            return 2;
        }
        user.setEmail((String)map.get("email"));
        user.setPost_id((int)map.get("post"));
        HashMap<String,Object> newMap = new HashMap<>();
        newMap.put("number",map.get("number"));
        newMap.put("id",map.get("enterpriseId"));
        if(consoleUserMapper.findSameNumber(newMap) !=null){
            if(loginMapper.findEmail((String)map.get("email")) != null){
                return 3;
            }
        }
        user.setEmployee_id((String)map.get("number"));
        consoleUserMapper.updateMember(user);
        return 4;
    }
}
